# Contributor: Michael Mason <ms13sp@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=iperf3
_pkgname=iperf
pkgver=3.9
pkgrel=0
pkgdesc="A tool to measure IP bandwidth using UDP or TCP"
url="https://github.com/esnet/iperf"
arch="all"
license="BSD-3-Clause"
subpackages="$pkgname-dev $pkgname-doc $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/esnet/$_pkgname/archive/$pkgver.tar.gz
	$pkgname.initd
	$pkgname.confd

	build-fixes.patch
	remove-pg-flags.patch
	"
builddir="$srcdir/$_pkgname-$pkgver"

build() {
	CFLAGS="$CFLAGS -D_GNU_SOURCE"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--disable-static
	make -j1
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="3da0939bed576a7c14baa03c996e6f407f20bfe58c4b3a36a66e74f41bd5442c0b23ab18c8eb1f2f37fd47449af533b61b658d810c68707b2b06d28894ac2035  iperf3-3.9.tar.gz
fdaf06316886ae02a865848ea6df6b77aecde78fab15bcbc22e077871c3f567521eeee19ef13c402fef467c2edd916a7d976a4c933dbfb637373145a18563ef9  iperf3.initd
4c6b766c154612f5f2e5f6150396f443ba37ec59ed0a8a994bf84612059db22827aee3dd3b7c3249e0bb6037163788d830efcb1caad5eba1c97d2349bdbc55f9  iperf3.confd
aef39e45bf63341b724b9131d8bfdf96702acc059e10d7d502053effa69a03097f64e9ba2a26c6a1e3e1567cf9a95013fc58b3b47623de79add14230bd820fa0  build-fixes.patch
9334d51ec4bb4931272f972a83109dadd44123c9b46803a5b2d16e725576b860f93b62ae3d85be2a2d8a955cff24211da7675fe733a4f3ad8aaae005939a4097  remove-pg-flags.patch"
